#include <cstdlib>
#include <iostream>
#include "game.h"
#include "enum.h"

using namespace std;

extern string Cmd;
extern int DeptStat[8];
extern bool event;

extern void Help(int Map);
extern void AutoSave();
extern void Store();
extern void GoOffice(int Senario);
extern void Debug();
extern bool debug;
extern int Rand(int Range);
extern void GetEvent();
extern void SetVar();

void ProcCmd(string Key);

Office gotoOffice;


void GetCmd()
{
     system("color 07");
     cout << "\n(INT_NUM)>>>";
     cin >> Cmd;
     cout << "\n";
     ProcCmd(Cmd);
}

void SetVar()
{
     gotoOffice.SetOffice();
}

void ProcCmd(string cmd)
{
     SetVar();
     int Key = atoi(cmd.c_str());
     switch(DeptStat[0])
     {
         case 0:
              if(Key == HELP)
              {
                     Help(DeptStat[0]);
              }
              else if (Key == OFFICE)
              {
                      int Sen;
                      getRand:
                      Sen = Rand(3);
                      if((gotoOffice.Shifu)&& (Sen == 1))
                      {
                       goto getRand;
                       gotoOffice.Shifu = true;
                      }
                      else if ((gotoOffice.Muye) && (Sen == 2))
                      {
                       goto getRand;
                       gotoOffice.Muye = true;
                      }
                       else
                      GoOffice(Sen);
                      
              }
              else if (Key == KILL)
              {
                      if(!event)
                      {
                                cout << "Who do you want to kill?\n";
                                system("pause");
                      }
              }
              else if (Key == FIND)
              {
                      cout << "Find option not available this time\n";
              }
              else if (Key == SHOP)
              {
                   Store();
              }
              else if (Key == DEBUG)
              {
                               Debug();
                               system("pause");
              }
              else if(Key == EXIT)
              {
                      AutoSave();
              }
              else
              {
                  cout << "Command not found, type HELP for help" << endl;
              }
              break;
                        
     
     }
}
